package com.example.lanouhn.firstapp.activity.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * 保存地址的数据库
 */
public class DBHelper extends SQLiteOpenHelper {
    //定义常量
    public static final String DATABASE_NAME = "address.db";
    public static final int DATABASE_VERSION = 2;
    public static final String TABLE_NAME = "address_table";

    public DBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
       //创建sql
        String sql = "CREATE TABLE " + TABLE_NAME + "( id integer PRIMARY KEY AUTOINCREMENT NOT NULL,name varchar(45) NOT NULL,phone varchar(45) NOT NULL,province varchar(45) NOT NULL,country varchar(45) NOT NULL)";
        db.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }



}
